{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "%load_ext rpy2.ipython"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [],
   "source": [
    "%%R\n",
    "X = c(1,2,3,4,5)\n",
    "Y = c(1,2,3,6,5)\n",
    "s = capture.output(summary(lm(Y~X)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lm(formula = Y ~ X)\n",
      "\n",
      "Residuals:\n",
      "         1          2          3          4          5 \n",
      " 1.239e-17 -2.000e-01 -4.000e-01  1.400e+00 -8.000e-01 \n",
      "\n",
      "Coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)  \n",
      "(Intercept)  -0.2000     1.0132  -0.197   0.8561  \n",
      "X             1.2000     0.3055   3.928   0.0294 *\n",
      "---\n",
      "Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n",
      "\n",
      "Residual standard error: 0.9661 on 3 degrees of freedom\n",
      "Multiple R-squared:  0.8372,\tAdjusted R-squared:  0.7829 \n",
      "F-statistic: 15.43 on 1 and 3 DF,  p-value: 0.02937\n"
     ]
    }
   ],
   "source": [
    "a =%R s\n",
    "for line in a[2:-1]:\n",
    "         print(line )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgCAMAAABKCk6nAAABwlBMVEUAAAAFBQUGBgYHBwcICAgJ\nCQkKCgoPDw8eHh4fHx8kJ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IP/CjXyyZ1ltm4u8OnGRrrY\nmaVgQ4eb9KfhPkNcatLNBdZMMjCcgeEMDGdgOAPDGRjOwHDNBc4C/axkURSlYYZOx5+ZbFocaNKD\nqNSsG/sC01DfqygbNp78+FtNxY/kIAkxcl50CBQ4KTduU1WSKA0TOE3y0l9UCcHOO3GoIzgu98M+\n+6foQpgjuBDqCI6zUIGjcpesXgRe7xH02obX9zA/OoNBqGvw6HJV4ijuQ+Ao5P8cEKRwFoe7ySqU\nuGTNfuAs1N3KeUEu76M73YA/l6TAAfumw+Ms3OU90BE8mnQ8/fYzH/j8wRDmm1WMHez2LeTfg0tM\n2n/JgjMwnIHhDAxnYDgDwxkYzsBwBoYzMJyB4QwMZ2A4A8MZGM7AcAaGMzCcgeEMDDfPgQfFhxMT\n+Ova5jlw8fHirMQnUHtprgMP65Z8lKt/5jpwPqCfoOc9cODHYmbBfAeOU/oleL4Dpwn+Jnq+A0dh\nH1ufCfSv71JGz5UP4CfpeQ48FwwMZ2A4A8MZGM7AcAaGMzCcgeEMDGdgOAPDGRjOwHAGhjMwnIHh\nDAxnYLjPALb3wPFaPXcPAAAAAElFTkSuQmCC\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%R plot(X,Y)"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
